package org.eclipse.epsilon.emc.spreadsheets.csv.common;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;

import org.eclipse.epsilon.common.util.FileUtil;
import org.eclipse.epsilon.emc.spreadsheets.csv.CsvConstants;
import org.eclipse.epsilon.emc.spreadsheets.csv.CsvModel;
import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
import org.junit.Test;

public class CommonTest
{
	private static CsvModel model = null;
	private static String filePath = "resources/CsvFile.txt";

	private static void setUp() throws Exception
	{
		model = new CsvModel();
		model.setFile(filePath);
		model.setConfigurationFile("resources/CsvFileTestConfig.xml");
		model.setHasHeader(true);
		model.setStoredOnDisposal(false);
		model.setName("MODEL");
		model.load();
	}

	@Test
	public void instantiateClasses()
	{
		new CsvConstants();
	}

	@Test
	public void loadEmptyHeaderWhenExpected() throws Exception
	{
		FileUtil.setFileContents("", new File(filePath));
		try
		{
			setUp();
			fail();
		}
		catch (EolModelLoadingException e)
		{
			assertTrue(true);
		}
	}
	
	@Test
	public void loadBlankHeaderWhenExpected() throws Exception
	{
		FileUtil.setFileContents("  ", new File(filePath));
		try
		{
			setUp();
			fail();
		}
		catch (EolModelLoadingException e)
		{
			assertTrue(true);
		}
	}

}
